/**
 * @version Create on 2012-11-2
 * @author Yinzi Chen
 */

public class LengthOfLastWord {

	public int lengthOfLastWord(String s) {
		s = s.trim();
		if (s.equals(""))
			return 0;
		int i = s.length() - 1;
		while (i >= 0 && s.charAt(i) != ' ') {
			i--;
		}
		return s.length() - i - 1;
	}

	public static void main(String[] args) {

	}

}
